﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HA.ModFlow.Domain.FileLayer
{
   public  class PDrain:Package
    {

       public PDrain()
       {
           this._fileType = FileType.DRN;

           this.Fname = "solution.drn";

           this.Nunit = 43;
       }




       int _MXACTD;

       public int MXACTD
       {
           get { return _MXACTD; }
           set { _MXACTD = value; }
       }

       int _IDRNCB=103;

       public int IDRNCB
       {
           get { return _IDRNCB; }
           set { _IDRNCB = value; }
       }



       List<SPDrain> _stressPeriodDrain=new List<SPDrain> ();

       public List<SPDrain> StressPeriodDrain
       {
           get { return _stressPeriodDrain; }
           
       }
     

     




       public override void WriteFile(string path)
       {
           string content = "# HuanAnKeJi DRN File" + "\r\n";
           content += string.Format("{0,10}", this.MXACTD)+" " + string.Format("{0,10}", this.IDRNCB )+"\r\n";
           string str="";
           foreach (SPDrain sp in StressPeriodDrain)
           {
               str += string.Format("{0,10}", sp.ITMP)+" " + string.Format("{0,10}", sp.NP) + "\r\n";
               if (sp.ITMP < 0)
               {

               }
               else
               {
                   for (int i = 0; i < sp.DrainData.Count; i++)
                   {
                       //Value 代表着Elevation	Drain的海拔高度，Value2 ，Value3 类推
                       str += string.Format("{0,10}", sp.DrainData[i].Layer) + " " + string.Format("{0,10}", sp.DrainData[i].Row) + " " + string.Format("{0,10}", sp.DrainData[i].Column) + " " +
                              string.Format("{0,10}", sp.DrainData[i].Value) + " " + string.Format("{0,10}", sp.DrainData[i].Value2) + "\r\n";//  string.Format("{0,10}", sp.DrainData[i].Value3) + "\r\n";
                   }
               }
           }
           content += str;
           string fname = path + this.Fname;
           HAUtil.FileOperations.WriteFile(fname, content);
       }


    }
}
